package com.anjufang.controller;


import com.anjufang.service.system.SourceDataUserService;
import com.anjufang.service.system.WebApiService;
import com.anjufang.service.user.UserCacheService;
import com.anjufang.utils.RSAEncryptDecrypt;
import com.anjufang.utils.Result;
import com.anjufang.utils.StringUtils;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 抽签
 */
@RestController
@RequestMapping("/api/")
@CrossOrigin
public class WebApiController extends BaseController {

    @Autowired
    private SourceDataUserService sourceUserService;

    @Autowired
    private WebApiService webApiService;

    @Autowired
    private UserCacheService userCacheService;

    @CrossOrigin(origins = "*")
    @RequestMapping("getByIdNumber")
    public Result getByIdNumber(String idNumber,String userName){
        if(StringUtils.isBlank(idNumber)){
            return Result.error("身份证号码不能为空");
        }
        return sourceUserService.getByIdNumber(idNumber,userName);
    }

    @CrossOrigin(origins = "*")
    @RequestMapping("group")
    public Result group(String idNumber){
        if(StringUtils.isBlank(idNumber)){
            return Result.error("身份证号码不能为空");
        }
        return webApiService.draw(idNumber);
    }
}
